using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class RX_detailsMap : EntityTypeConfiguration<RX_details>
    {
        public RX_detailsMap()
        {
            // Primary Key
            this.HasKey(t => t.id);

            // Properties
            this.Property(t => t.Note)
                .HasMaxLength(100);

            this.Property(t => t.TXTDrug)
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("RX_details");
            this.Property(t => t.id).HasColumnName("id");
            this.Property(t => t.RXID).HasColumnName("RXID");
            this.Property(t => t.Form).HasColumnName("Form");
            this.Property(t => t.UOM).HasColumnName("UOM");
            this.Property(t => t.Frequency).HasColumnName("Frequency");
            this.Property(t => t.DispenseTime).HasColumnName("DispenseTime");
            this.Property(t => t.Instruction).HasColumnName("Instruction");
            this.Property(t => t.Duration).HasColumnName("Duration");
            this.Property(t => t.Strength).HasColumnName("Strength");
            this.Property(t => t.Note).HasColumnName("Note");
            this.Property(t => t.Refills).HasColumnName("Refills");
            this.Property(t => t.DX).HasColumnName("DX");
            this.Property(t => t.Generic).HasColumnName("Generic");
            this.Property(t => t.Medication).HasColumnName("Medication");
            this.Property(t => t.TXTDrug).HasColumnName("TXTDrug");
            this.Property(t => t.Route).HasColumnName("Route");
            this.Property(t => t.DispenseAsWritten).HasColumnName("DispenseAsWritten");
            this.Property(t => t.Qty).HasColumnName("Qty");

            // Relationships
            this.HasOptional(t => t.RX_DispenseTime)
                .WithMany(t => t.RX_details)
                .HasForeignKey(d => d.DispenseTime);
            this.HasOptional(t => t.RX_Form)
                .WithMany(t => t.RX_details)
                .HasForeignKey(d => d.Form);
            this.HasOptional(t => t.RX_Frequency)
                .WithMany(t => t.RX_details)
                .HasForeignKey(d => d.Frequency);
            this.HasOptional(t => t.RX_instruction)
                .WithMany(t => t.RX_details)
                .HasForeignKey(d => d.Instruction);
            this.HasOptional(t => t.Rx_Medication)
                .WithMany(t => t.RX_details)
                .HasForeignKey(d => d.Medication);
            this.HasOptional(t => t.RX_Prescription)
                .WithMany(t => t.RX_details)
                .HasForeignKey(d => d.RXID);
            this.HasOptional(t => t.rx_Route)
                .WithMany(t => t.RX_details)
                .HasForeignKey(d => d.Route);
            this.HasOptional(t => t.Rx_UOM)
                .WithMany(t => t.RX_details)
                .HasForeignKey(d => d.UOM);

        }
    }
}
